import 'package:flutter/material.dart';
import 'package:ft_reader/pages/details/category_page.dart';
import 'package:ft_reader/pages/store/list_page.dart';
import 'package:ft_reader/pages/store/sex_page.dart';

class BookStore extends StatefulWidget {
  @override
  _BookStore createState()  => _BookStore();

}

class _BookStore extends State<BookStore>
    with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin{
  List<String> _tabTitle = ['男生', '女生', '分类', '专题'];

  TabController _tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    // SingleTickerProviderStateMixin
    _tabController = new TabController(
        length: _tabTitle.length, vsync: this);
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        brightness: Brightness.light, // 亮度
        backgroundColor: Colors.white,
        title: Container(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              Container(
                child: Text(
                  '书城',
                  style: TextStyle(
                    color: Theme.of(context).primaryColor,
                    fontSize: 26.0,
                    letterSpacing: 2,
                    fontWeight: FontWeight.bold
                  ),
                ),
              ),
              Expanded(
                child: Container(
                  margin: EdgeInsets.only(left: 15),
                  child: TabBar(
                    tabs: _tabTitle.map((title) {
                      return Tab(text: title,);
                    }).toList(),
                    labelStyle: TextStyle(
                      fontSize: 18,
                      fontWeight: FontWeight.bold
                    ),
                    unselectedLabelStyle: TextStyle(
                      fontSize: 16
                    ),
                    indicatorColor: Theme.of(context).primaryColor,
                    labelColor: Theme.of(context).primaryColor,
                    unselectedLabelColor: Colors.black54,
                    controller: _tabController,
                  ),
                ),
              )
            ],
          ),
        ),
        centerTitle: true,
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: TabBarView(
              children: <Widget>[
                SexPage(sex: 'man',),
                SexPage(sex: 'lady',),
                CategoryPage(),
                ListPage()
              ],
              controller: _tabController,
            ),
          )
        ],
      ),
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;

}